package com.river.springbootdemo.thinkingjava.innerclass.controller;

/**
 * the common method for any control event
 */
public abstract class Event {
    private long eventTime;
    protected final long delayTime;

    public Event(long delayTime) {
        this.delayTime = delayTime;
        start();
    }

    public void start() {
        eventTime = System.nanoTime() + delayTime;
    }

    public boolean ready() {
        return System.nanoTime() >= eventTime;
    }

    public abstract void action();

    @Override
    public String toString() {
        return "Event{" +
                "eventTime=" + eventTime +
                ", delayTime=" + delayTime +
                '}';
    }
}
